<template>
	<view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="item_l">
					<view class="item_name">{{item.remark}}</view>
					<view class="item_time">{{item.createtime}}</view>
				</view>
				<view class="item_r">
					{{item.money}}
				</view>
			</view>
			<view class="flex-center addressImgBox" v-if="list.length==0">
				<image src="https://wx.2024csnl.com/static/noData.png"></image>
				暂无数据~
			</view>
			<view style="text-align: center;color: #999;" v-if="noMoreData&&list.length!=0">没有更多啦~</view>
		</view>
	</view>
</template>

<script>
	import {
		merchantScoreDetails
	} from "../../api/index.js"
	export default {
		data() {
			return {
				list: [],
				pagenum: 1,
				totalPage: '',
				noMoreData: false,
				bid: '',

			}
		},
		onLoad(opt) {

			this.bid = opt.bid
			this.getMerchantScoreDetails()

		},
		onReachBottom() {
			if (this.pagenum < this.totalPage) {
				this.pagenum += 1
				this.getMerchantScoreDetails('bottom')

			} else {
				this.noMoreData = true
			}

		},
		methods: {

			async getMerchantScoreDetails(type) {
				console.log(this.bid)
				const res = await merchantScoreDetails('s=/ApiBusiness/bmoneylog', {
					bid: this.bid,
					pagenum: this.pagenum
				})
				const {
					msg,
					data,
					status,
				} = res.data
				console.log(res, "res")
				if (status == 1) {
					this.totalPage = data.last_page
					type == 'bottom' ? this.list.push(...data.data) : this.list = data.data
					this.pagenum != 1 && data.length == 0 ? this.noMoreData = true : this.noMoreData = false

				} else {
					this.showToast(msg)
				}
			},

		}
	}
</script>

<style lang="scss" scoped>
	.addressImgBox {
		flex-direction: column;
		color: #999;
		padding-top: 20%;

		image {
			width: 400rpx;
			height: 400rpx;
		}
	}

	.list {
		.item {
			padding: 28upx 52upx 28upx 30upx;
			box-sizing: border-box;
			border-radius: 10upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #fff;
			margin-bottom: 20upx;

			.item_l {
				.item_name {
					font-size: 28upx;
					line-height: 28upx;
					font-weight: 400;
					margin-bottom: 10upx;
				}

				.item_time {
					margin-top: 30rpx;
					font-size: 26upx;
					line-height: 26upx;
					color: #999;
				}
			}
		}
	}
</style>
